# Created by yang

import inspect


class Variable(dict):
    def __getitem__(self, item):
        if hasattr(self, item):
            return getattr(self, item)
        else:
            raise AttributeError("{} object has no attribute {}".format(self.__obj, item))

    def __init__(self):
        obj_list = inspect.stack()[1][-2]
        self.__obj = obj_list[0].split('=')[0].strip()
        print(self.__obj)

    # def __getattr__(self, item):
    #     print(item)

if __name__ == '__main__':
    VAR = Variable()

    VAR.ss = "555"
    print(VAR.ss)
    print(VAR["ss1"])
